<?php

namespace App\Models\Admin;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class SysMenu extends Model
{
    use HasFactory;

    protected $fillable = [
        'name', 'path', 'component', 'redirect', 'meta'
    ];

    protected $hidden = ['pivot', 'created_at', 'updated_at', 'id', 'parent_id'];

    protected $casts = [
        'meta' => 'array',
    ];

    // protected $append = ['meta'];

    public function children()
    {
        return $this->hasMany(SysMenu::class, 'parent_id', 'id')->with('children');
    }
}
